<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ include file="/jsp/common/common.jsp"%>  

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title></title>
		<meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
		<link rel="stylesheet" type="text/css"
    href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
    href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
<link rel="Stylesheet" type="text/css"
    href="<c:url value="/static/css/jquery.ui.css"/>" />
<script type="text/javascript"
    src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/js/showMsg.js"/>"></script>
<script type="text/javascript"
    src="<c:url value="/static/listBox/jquery.clever.listbox.js"/>"></script>
<script type="text/javascript"
            src="<c:url value="/static/js/common.js"/>"></script>       

		
		<script>
	        var dataLeft ;

			function initList(listDisplayEId) {
				$('#' + listDisplayEId).datagrid(
						{
							nowrap : false,
							striped : true,
							collapsible : true,
							remoteSort : true,
							notSelectByRow : false,
							toolbar : [
                                {
                                    id : listDisplayEId + '_btn_save',
                                    text : 'Excel报表导出',
                                    iconCls : 'icon-print',
                                    handler : function() {
                                        excel();
                                    }
                                }           
							],
							onLoadError:function(){
								$.messager.alert('错误','获取数据失败，请与管理员联系！','error');
							}
						});
			};
			$(document).ready(function() {
				document.getElementById('custIdAll').value = '';
                document.getElementById('zzy').style.display = 'none';
				initList('listDisplay');
			});
			
			//导出报表
			function excel(){
                $('#searchForm').form('submit',
                        {
                            url:'<c:url value='/check/exportCheckExcel.do'/>', //查询提交路径
                            onSubmit:function()//提交按钮相应函数
                            {
                                return $('#searchForm').form('validate');
                            },
                            success:function(data){
                                data = eval( "("+data+")" );
                                if(data.success){
                                    $.messager.alert("提示", "导出成功！",'info', function(){
                                        window.close();
                                    });
                                }else{
                                    $.messager.alert("提示", data.msg, 'warning');
                                }
                            },
                            error:function(){
                                $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
                                return;
                            }
                        }
                );
            }
			$(function() {      
				$('#ordSupId').combobox({   
                    url:"<c:url value='/store/pulldownSupId.do?space=0'/>",   
                    editable:false, //不可编辑状态  
                    cache: false,  
                    valueField:'supId',     
                    textField:'supName'
                });
                $("#custName").textbox({
                    buttonText:'选择',    
                    iconCls:'icon-man', 
                    iconAlign:'left',
                    editable:false,
                    value: "全部",
                    onClickButton:function(){

                        initDateLeft();
                        showMsgLeft();
                        ShowDiv();

                        var left = $('#left').listbox();
                        var items = left.getDatas();
                        left.removeRange(items);

                        var right = $('#right').listbox();
                        var itemsr = right.getDatas();
                        right.removeRange(itemsr);

                        $('#left').listbox().reload({
                            data : dataLeft,
                            ajaxsettings : {
                                data : {
                                    id : 'a'
                                }
                            }
                        });
                    }
                });
                //隐藏div界面
                $('#provinceShow').combobox(
                        {
                            url : '<c:url value='/user/pullDownProvince.do'/>' +'?space=1',
                            editable : true, //不可编辑状态  
                            cache : false,
                            panelHeight : '150',
                            valueField : 'areaid',
                            textField : 'name',
                            required : true,
                            value:0,
                            onChange : function(newValue, oldValue) {
                                $.post('<c:url value='/user/pullDownCity.do'/>'+'?space=1', {
                                    parentId : newValue
                                }, function(data) {
                                    $('#cityShow').combobox("clear").combobox(
                                            'loadData', data);
                                    $('#cityShow').combobox('setValue',0);
                                }, 'json');
                            }
                        });
                $('#cityShow').combobox(
                        {
                            valueField : 'areaid',
                            textField : 'name',
                            editable : false,
                            url : '<c:url value='/user/pullDownCity.do'/>'+'?space=1',
                            value:0,
                            onChange : function(newValue, oldValue) {
                                $.post('<c:url value='/user/pullDownCountry.do'/>'+'?space=1', {
                                    parentId : newValue
                                }, function(data) {
                                    $('#countryShow').combobox("clear").combobox(
                                            'loadData', data);
                                    $('#countryShow').combobox('setValue',0)
                                }, 'json');
                            }
                        });
                $('#countryShow').combobox({
                    url : '<c:url value='/user/pullDownCountry.do'/>'+'?space=1',
                    valueField : 'areaid',
                    textField : 'name',
                    value:0,
                    editable : false
                });
            });
			function searchInfo(){
				if($('#ordDateStart').combobox('getValue') ==''){
					alert("起始日不能为空");
				}else if($('#ordDateEnd').datebox('getValue') ==''){
					alert("截止日不能为空");
				}else{
				        $('#listDisplay').datagrid('load', {
				        	initFlag : 1,
				        	ordDateEnd : $('#ordDateEnd').datebox('getValue'),
				        	ordDateStart : $('#ordDateStart').datebox('getValue'),
				        	custIdAll : $('#custIdAll').val()
						});  
				}
			}
			function ShowDiv() {
		        var Allwidth = '100%';
		        var Allheight = '100%';
		        document.getElementById('zzy').style.display = '';
		        Loading.Show({
		            width : Allwidth,
		            height : Allheight
		        });
		    }
			
		//获取data 数据
		function initDateLeft(){
			$.ajax({
			    async : false,
			    url : "<c:url value='/user/userTestValue.do'/>",
			    type : "post",
			    success : function(data) {
			    	dataLeft = data;
	                if (typeof (dataLeft) == 'string' && dataLeft!='') {
	                        dataLeft = JSON.parse(dataLeft);
	                }
			    }
			});
		}
		//初始化showMsg
        function showMsgLeft() {
            $('#left').listbox({
                data: dataLeft,
                height: 300,
                width: 200,
                dndscope: 'demo',
                dnd: false,
                multiselect: true,
                selectchange: function (data) {
                    if (data && data.length > 0) {
                        $('#btnRight').attr('disabled', false);
                    } else {
                        $('#btnRight').attr('disabled', true);
                    }
                }
            });
            var data = [{ value: 10, text: 'think8848' },
            { value: 20, text: 'aCloud' },
            { value: 21, text: 'aaaaa' },
            { value: 36, text: 'qqqqq'}];
            $('#right').listbox({
                //data: data,
                height: 300,
                width: 200,
                dndscope: 'demo',
                dnd: true,
                multiselect: true
            });
            $('#btnRightAll').click(function () {
                var left = $('#left').listbox();
                var items = left.getDatas();
                left.clear();
                $('#right').listbox().addRange(items);
            });
            $('#btnLeftAll').click(function () {
                var right = $('#right').listbox();
                var items = right.getDatas();
                right.clear();
                $('#left').listbox().addRange(items);
            });
            $('#btnRight').click(function () {
                var left = $('#left').listbox();
                var items = left.getSelected();
                left.removeRange(items);
                $('#right').listbox().addRange(items);
            });
            $('#btnLeft').click(function () {
                var right = $('#right').listbox();
                var items = right.getSelected();
                right.removeRange(items);
                $('#left').listbox().addRange(items);
            });
            $('#btnRemove').click(function () {
                $('#right').listbox().removeRange([{ value: 2 }, { value: 26}]);
            });
            $('#btnSelect').click(function () {
                var selected = $('#right').listbox().getSelected();
                var msg = 'Selected count is: ' + selected.length;
                if (selected.length > 0) {
                    msg += ', The first item text is: ' + selected[0].text;
                }
                msg += '.';
                alert(msg);
            });
            $('#btnGetItems').click(function () {
                var selected = $('#right').listbox('getDatas');
                alert('Items count is: ' + selected.length);
            });
            $('#btnSetSelection').click(function () {
                $('#left').listbox('setSelection', 1);
            });
            $('#select').click(function() {
                Loading.Hide();
                document.getElementById('zzy').style.display = 'none';

                var right = $('#right').listbox();
                var items = right.getDatas();
                var userNames = '';
                var userIds = '';
                if(items.length >0){
                    for ( var e in items) {
                        userNames = userNames + items[e].text + ',' ;
                        userIds = userIds + items[e].value + ',' ;
                    }
                    userNames = userNames.substring(0,userNames.length-1);
                    userIds = userIds.substring(0,userIds.length-1);
                }
                if (userNames != '' && userIds != '') {
                    $('#custName').textbox('setValue', userNames);
                    document.getElementById('custIdAll').value = userIds;
                } else {
                    $('#custName').textbox('setValue', '全部');
                    document.getElementById('custIdAll').value = '';
                }
            });
            $('#noselect').click(function() {
                Loading.Hide();
                document.getElementById('zzy').style.display = 'none';
            });
		}
		
        function searchInfoForShowCust(){
            $('#searchFormForShowCust').form('submit',
                {
                    url:'<c:url value='/user/checkCustlook.do'/>', //查询提交路径
                    onSubmit:function()//提交按钮相应函数
                        {
                            return $('#searchFormForShowCust').form('validate');
                        },
                    success:function(data){
                        data = eval( "("+data+")" );
                        /* var left = $('#left').listbox();
                        var items = left.getDatas();
                        left.removeRange(items); */

                        /* var right = $('#right').listbox();
                        var itemsr = right.getDatas();
                        right.removeRange(itemsr); */
                        $('#left').listbox().reload({
                            data : data,
                            ajaxsettings : {
                                data : {
                                    id : 'a'
                                }
                            }
                        });
                    },
                    error:function(){
                        $.messager.alert("错误", "系统错误，请联系管理员！", 'error');
                        return;
                    }
                }
            );
        }
        //查看详细内容
        function  goDetailedContent(val,rowData,rowIndex){
            return '<a href="#" onclick="constructionManager(\'' + rowData.ordId+ '\',\'' + rowData.ordSupId + '\')">'+val+'</a>  '
        }
        function constructionManager(id,supId) {
            var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/order/goSupperDetailed.do'/>"+"?id="+id+"&supId="+supId,"sun","width=1200px,height=600px,status=no,scrollbars=yes");
            
            new_win.focus();
        }
        // 颜色
        function cellStyler(value, row, index) {
            if(row['ordPaymentState']==1){
                return 'color:red;';
            }
        }
    </script>
			</head>
			<body>
			<table width="98%">
			<tr><td>
			<div style="height: auto; width:100%;background: #fafafa; padding: 5px;" class="easyui-panel" title="检索条件" iconCls="icon-search" collapsible="true" minimizable="false" maximizable="false" closable="false">
					<form id="searchForm" name="searchForm" method="post">
						<div>
		            	<table cellpadding="5">
								<tr>
									<td>起始日期</td>
									<td><input class="easyui-datebox" editable="false" id="ordDateStart" name="ordDateStart" required="true"></input></td>
									<td>截止日期</td>
                                    <td><input class="easyui-datebox" editable="false" id="ordDateEnd" name="ordDateEnd" required="true"></input></td>
                                </tr>
                                <tr>
                                    <td>客户</td>
                                    <td colspan="3"><input style="width:360px" id="custName" name="custName" ></input></td>
		                    		
		                    	</tr>
		                    	<tr>
                                    <td>供应商</td>
                                    <td><input class="easyui-combobox" name="ordSupId" id="ordSupId" editable="false"  /></td>
                                </tr>
		                    	<tr>
		                    	    <td><input type="button" onclick="searchInfo()" value="查询"></td>
		                    	</tr>
		                    	<td><input class="easyui-validatebox" editable="false" id="custIdAll" name="custIdAll" type="hidden" ></input></td>
		                    	
		                </table>
						</div>
					</form>
				</div>
			</td></tr>
            </table>
			<table width="98%">
		      <tr>
		      <td>
		         <table id="listDisplay" title="供应商订单列表" singleSelect=true
                    iconCls="icon-list" idField="id"
                    url="<c:url value="/accountForCaiwu/findCaiwuCheck.do"/>"
                    style="width: 100%;" loadMsg="请稍候......"
                    pagination="true" pageSize="10"
                    pageList="[10,20,30,40,50,100,150,200]" sortName="roleId"
                    rownumbers="true" sortOrder="asc" showFooter="true">
			     <thead>
				    <tr>
                            <th field="id" width="25" align="center"  checkbox="true">
                            </th> 
                            <th field="ordId" width="80"  sortable="true" > 订单ID
                            </th>   
                            <th field="ordCustId" width="80" sortable="true" hidden="true"> 客户ID
                            </th>   
                            <th field="ordCustName" width="80" sortable="true" > 客户名
                            </th>   
                            <th field="ordSupId" width="80" sortable="true" hidden="true"> 供货商ID
                            </th>       
                            <th field="ordSupName" width="80" sortable="true" > 供货商名
                            </th>   
                            <th field="ordState" width="120"  formatter="formatOrdStateSupper" sortable="true" >订单状态
                            </th>   
                            <th field="ordPaymentState" width="80" formatter="formatOrdPaymentState" sortable="true"  styler="cellStyler" >结款状态
                            </th> 
                            <th field="commitDeliverState" width="80" formatter="formatCommitDeliverState" sortable="true" >材料实际重量
                            </th>   
                            <th field="ordDate" width="150" sortable="true" >订单日期
                            </th>
                            <th field="ordDay" width="80"  sortable="true" >订单日
                            </th>   
                            <th field="ordValueReal" width="70"  sortable="true" >送货总价
                            </th>
                            <th field="ordValueRealCost" width="70"  sortable="true" >进货总价
                            </th>  
                            <th field="turnover" width="70"  sortable="true" >营业额
                            </th>  
                            <th field="grossMargin" width="100"  sortable="true" >毛利率
                            </th>  
                            <th field="content" width="100" formatter="goDetailedContent" sortable="true" >根据检索条件
                            </th>
                            <!-- 
                            <th field="content" width="110" formatter="goDetailedContent" sortable="true" >
                                进入修改品级页面
                            </th>   
                            <th field="content2" width="110" formatter="goDetailedContent2" sortable="true" >
                                查看实际送货内容
                            </th>   
                             -->    
                        </tr>
			     </thead>
			     </table>
			</td>
			</tr>
		</table>
		<div
        style='position: absolute; left: 40px; top: 40px; z-index: 101; background-color: #FFFFFF; border-radius: 10px; width: 550px;'
        id="zzy">
        <table align="center">
            <tr>
                <td colspan="3">
                    <form id="searchFormForShowCust" name="searchFormForShowCust" method="post" accept-charset="UTF-8">
                    <div
                        style="height: auto; width: 470px; background: #fafafa; padding: 5px;"
                        class="easyui-panel" title="查询" iconCls="icon-search"
                        collapsible="true" minimizable="false" maximizable="false"
                        closable="false">
                        <table>
                            <tr>
                                <td>省:</td>
                                <td><input class="easyui-combobox" name="provinceShow"
                                    id="provinceShow" required="true" /></td>
                                <td>市:</td>
                                <td><input class="easyui-combobox" name="cityShow"
                                    id="cityShow" required="true" /></td>
                            </tr>
                            <tr>
                                <td>区:</td>
                                <td><input class="easyui-combobox" name="countryShow"
                                    id="countryShow" required="true" /></td>
                                <td colspan="2"><a href="#" class="easyui-linkbutton"
                                    data-options="iconCls:'icon-search'" style="width: 60px"
                                    onclick="searchInfoForShowCust()">查询</a></td>
                            </tr>
                        </table>
                    </div>
                    </form>
                </td>
            </tr>
            <tr>
                <td>
                    <ul id="left">
                    </ul>
                </td>
                <td><input type="button" value="&gt;&gt;" id="btnRightAll"
                    style="width: 50px;" /><br /> <input type="button" value="&gt;"
                    id="btnRight" style="width: 50px;" /><br /> <input type="button"
                    value="&lt;" id="btnLeft" style="width: 50px;" /><br /> <input
                    type="button" value="&lt;&lt;" id="btnLeftAll" style="width: 50px;" />
                </td>
                <td>
                    <ul id="right">
                    </ul>
                </td>
            </tr>
        </table>
        <table align="center">
            <tr>
                <!--  
                <td><input type="button" value="Add Item" id="btnAdd" /></td>
                <td><input type="button" value="Remove Item" id="btnRemove" /></td>
                <td><input type="button" value="Get Select" id="btnSelect" /></td>
                <td><input type="button" value="Get Items" id="btnGetItems" /></td>
                <td><input type="button" value="SetSelection (value equal to '1')" id="btnSetSelection" /></td>
                <td><input type="button" value="Reload" id="btnReload" /></td>
                -->
                <td><input type="button" value="取消" id="noselect" /></td>
                <td width="200px"></td>
                <td><input type="button" value="选择" id="select" /></td>

            </tr>
        </table>
    </div>
	</body>
</html>